/*
 * @Author: ChunLai
 * @Date: 2023-07-25 09:48:14
 * @LastEditTime: 2023-08-17 14:24:57
 * @Description:险种信息保存接口
 * @FilePath: \0.newInsure\src\translate\risks\insert.js
 */

import store from '@/store/index';
/**
 * 数据库险种信息 >>> store回显
 * @param {*} data
 * @returns
 */
export const GetRiskData = (data) => {
  let riskData = []; // 接口数据
  data.forEach((item) => {
    let data = {
      varietyCode: item.riskCode,
      checked: true,
      payendyear: item.insureDuration === '1000' ? '趸交' : item.insureDuration,
      amnt: item.amnt,
      insuYear: item.insureYear,
      prem: item.prem,
      mult: item.mult,
    };
    // console.log("watch3")
    store.commit('risks/SET_RISKSTATE');
    if (item.renewFlag) {
      data.renewFlag = item.renewFlag;
    }
    if (item.getYear) {
      data.pullAge = item.getYear;
    }
    if (item.getIntv) {
      data.pullMethod = item.getIntv;
    }
    if (item.getMode) {
      data.getMode = item.getMode;
    }
    // 计划编码: 多选责任转化 + 计划选择
    if (item.planCode) {
      data.planCode = item.planCode;
    }
    // 可选责任列表 --- 类型2回显数据(liabilityList >>> list)
    if (item.dutys && item.dutys.length > 0) {
      data.dutys = item.dutys;
    }
    riskData.push(data);
  });
  return riskData;
};
